package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDictServer extends UDPEchoServer{

    //创建一个哈希表
    private HashMap<String,String> dict = null;
    public UdpDictServer(int port) throws SocketException {
        super(port);
        dict = new HashMap<>();
        dict.put("Animal","动物");
        dict.put("apple","苹果");
        dict.put("hello","你好");
        dict.put("bonus","红利");
    }

    //重写process方法

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"没有该单词");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
